home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / wgdb-42.lha / wgdb-4.2 / gdb / gdb.info-4 < prev    next >
Text File  |  1992-09-11  |  45KB  |  1,269 lines

  1. Info file gdb.info, produced by Makeinfo, -*- Text -*- from input
  2. file gdb-all.texi.
  3.  
  4.    This file documents the GNU debugger GDB.
  5.  
  6.    Copyright (C) 1988, 1989, 1990, 1991 Free Software Foundation, Inc.
  7.  
  8.    Permission is granted to make and distribute verbatim copies of
  9. this
  10. manual provided the copyright notice and this permission notice are
  11. preserved on all copies.
  12.  
  13.    Permission is granted to copy and distribute modified versions of
  14. this
  15. manual under the conditions for verbatim copying, provided also that
  16. the section entitled "GNU General Public License" is included
  17. exactly as in the original, and provided that the entire resulting
  18. derived work is distributed under the terms of a permission notice
  19. identical to this one.
  20.  
  21.    Permission is granted to copy and distribute translations of this
  22. manual into another language, under the above conditions for
  23. modified versions, except that the section entitled "GNU General
  24. Public License" may be included in a translation approved by the
  25. Free Software Foundation instead of in the original English.
  26.  
  27. 
  28. File: gdb.info,  Node: Type Checking,  Next: Range Checking,  Prev: Checks,  Up: Checks
  29.  
  30. An overview of type checking
  31. ----------------------------
  32.  
  33.    Some languages, such as Modula-2, are strongly typed, meaning that
  34. the arguments to operators and functions have to be of the correct
  35. type, otherwise an error occurs.  These checks prevent type mismatch
  36. errors from ever causing any run-time problems.  For example,
  37.  
  38.      1 + 2 => 3
  39.      error--> 1 + 2.3
  40.  
  41.    The second example fails because the `CARDINAL' 1 is not
  42. type-compatible with the `REAL' 2.3.
  43.  
  44.    For expressions you use in GDB commands, you can tell the GDB type
  45. checker to skip checking; to treat any mismatches as errors and
  46. abandon the expression; or only issue warnings when type mismatches
  47. occur, but evaluate the expression anyway.  When you choose the last
  48. of these, GDB evaluates expressions like the second example above,
  49. but also issues a warning.
  50.  
  51.    Even though you may turn type checking off, other type-based
  52. reasons may prevent GDB from evaluating an expression.  For
  53. instance, GDB does not know how to add an `int' and a `struct foo'. 
  54. These particular type errors have nothing to do with the language in
  55. use, and usually arise from expressions, such as the one described
  56. above, which make little sense to evaluate anyway.
  57.  
  58.    Each language defines to what degree it is strict about type.  For
  59. instance, both Modula-2 and C require the arguments to arithmetical
  60. operators to be numbers.  In C, enumerated types and pointers can be
  61. represented as numbers, so that they are valid arguments to
  62. mathematical operators.  *Note Supported Languages: Support, for
  63. futher details on specific languages.
  64.  
  65.    GDB provides some additional commands for controlling the type
  66. checker:
  67.  
  68. `set check type auto'
  69.      Set type checking on or off based on the current working language.
  70.      *Note Supported Languages: Support, for the default settings
  71.      for each language.
  72.  
  73. `set check type on'
  74. `set check type off'
  75.      Set type checking on or off, overriding the default setting for
  76.      the current working language.  Issue a warning if the setting
  77.      does not match the language's default.  If any type mismatches
  78.      occur in evaluating an expression while typechecking is on, GDB
  79.      prints a message and aborts evaluation of the expression.
  80.  
  81. `set check type warn'
  82.      Cause the type checker to issue warnings, but to always attempt
  83.      to evaluate the expression.  Evaluating the expression may
  84.      still be impossible for other reasons.  For example, GDB cannot
  85.      add numbers and structures.
  86.  
  87. `show type'
  88.      Show the current setting of the type checker, and whether or not
  89.      GDB is setting it automatically.
  90.  
  91. 
  92. File: gdb.info,  Node: Range Checking,  Prev: Type Checking,  Up: Checks
  93.  
  94. An overview of Range Checking
  95. -----------------------------
  96.  
  97.    In some languages (such as Modula-2), it is an error to exceed the
  98. bounds of a type; this is enforced with run-time checks.  Such range
  99. checking is meant to ensure program correctness by making sure
  100. computations do not overflow, or indices on an array element access
  101. do not exceed the bounds of the array.
  102.  
  103.    For expressions you use in GDB commands, you can tell GDB to
  104. ignore range errors; to always treat them as errors and abandon the
  105. expression; or to issue warnings when a range error occurs but
  106. evaluate the expression anyway.
  107.  
  108.    A range error can result from numerical overflow, from exceeding
  109. an array index bound, or when you type in a constant that is not a
  110. member of any type.  Some languages, however, do not treat overflows
  111. as an error.  In many implementations of C, mathematical overflow
  112. causes the result to "wrap around" to lower values--for example, if
  113. M is the largest integer value, and S is the smallest, then
  114.  
  115.      M + 1 => S
  116.  
  117.    This, too, is specific to individual languages, and in some cases
  118. specific to individual compilers or machines.  *Note  Supported
  119. Languages: Support, for further details on specific languages.
  120.  
  121.    GDB provides some additional commands for controlling the range
  122. checker:
  123.  
  124. `set check range auto'
  125.      Set range checking on or off based on the current working
  126.      language.
  127.      *Note Supported Languages: Support, for the default settings
  128.      for each language.
  129.  
  130. `set check range on'
  131. `set check range off'
  132.      Set range checking on or off, overriding the default setting for
  133.      the current working language.  A warning is issued if the
  134.      setting does not match the language's default.  If a range
  135.      error occurs, then a message is printed and evaluation of the
  136.      expression is aborted.
  137.  
  138. `set check range warn'
  139.      Output messages when the GDB range checker detects a range
  140.      error, but attempt to evaluate the expression anyway. 
  141.      Evaluating the expression may still be impossible for other
  142.      reasons, such as accessing memory that the process does not own
  143.      (a typical example from many UNIX systems).
  144.  
  145. `show range'
  146.      Show the current setting of the range checker, and whether or
  147.      not it is being set automatically by GDB.
  148.  
  149. 
  150. File: gdb.info,  Node: Support,  Prev: Checks,  Up: Languages
  151.  
  152. Supported Languages
  153. ===================
  154.  
  155.    GDB 4.2 supports C, C++, and Modula-2.  The syntax for C and C++
  156. is so closely related that GDB does not distinguish the two.  Some
  157. GDB features may be used in expressions regardless of the language
  158. you use: the GDB `@' and `::' operators, and the `{type}addr'
  159. construct (*note Expressions::.) can be used with the constructs of
  160. any of the supported languages.
  161.  
  162.    The following sections detail to what degree each of these source
  163. languages is supported by GDB.  These sections are not meant to be
  164. language tutorials or references, but serve only as a reference
  165. guide to what the GDB expression parser will accept, and what input
  166. and output formats should look like for different languages.  There
  167. are many good books written on each of these languages; please look
  168. to these for a language reference or tutorial.
  169.  
  170. * Menu:
  171.  
  172. * C::                           C and C++
  173. * Modula-2::                    Modula-2
  174.  
  175. 
  176. File: gdb.info,  Node: C,  Next: Modula-2,  Prev: Support,  Up: Support
  177.  
  178. C and C++
  179. ---------
  180.  
  181.    Since C and C++ are so closely related, GDB does not distinguish
  182. between them when interpreting the expressions recognized in GDB
  183. commands.
  184.  
  185.    The C++ debugging facilities are jointly implemented by the GNU
  186. C++ compiler and GDB.  Therefore, to debug your C++ code
  187. effectively, you must compile your C++ programs with the GNU C++
  188. compiler, `g++'.
  189.  
  190. * Menu:
  191.  
  192. * C Operators::                 C and C++ Operators
  193. * C Constants::                 C and C++ Constants
  194. * Cplusplus expressions::       C++ Expressions
  195. * C Defaults::                  Default settings for C and C++
  196. * C Checks::                    C and C++ Type and Range Checks
  197. * Debugging C::                 GDB and C
  198. * Debugging C plus plus::       Special features for C++
  199.  
  200. 
  201. File: gdb.info,  Node: C Operators,  Next: C Constants,  Prev: C,  Up: C
  202.  
  203. C and C++ Operators
  204. ...................
  205.  
  206.    Operators must be defined on values of specific types.  For
  207. instance, `+' is defined on numbers, but not on structures. 
  208. Operators are often defined on groups of types.  For the purposes of
  209. C and C++, the following definitions hold:
  210.  
  211.    * *Integral types* include `int' with any of its storage-class
  212.      specifiers, `char', and `enum's.
  213.  
  214.    * *Floating-point types* include `float' and `double'.
  215.  
  216.    * *Pointer types* include all types defined as `(TYPE *)'.
  217.  
  218.    * *Scalar types* include all of the above.
  219.  
  220. The following operators are supported.  They are listed here in order
  221. of increasing precedence:
  222.  
  223. `,'
  224.      The comma or sequencing operator.  Expressions in a
  225.      comma-separated list are evaluated from left to right, with the
  226.      result of the entire expression being the last expression
  227.      evaluated.
  228.  
  229. `='
  230.      Assignment.  The value of an assignment expression is the value
  231.      assigned.  Defined on scalar types.
  232.  
  233. `OP='
  234.      Used in an expression of the form A OP`=' B, and translated to A
  235.      `=' A OP B.  OP`=' and `=' have the same precendence.  OP is
  236.      any one of the operators `|', `^', `&', `<<', `>>', `+', `-',
  237.      `*', `/', `%'.
  238.  
  239. `?:'
  240.      The ternary operator.  `A ? B : C' can be thought of as:  if A
  241.      then B else C.  A should be of an integral type.
  242.  
  243. `||'
  244.      Logical OR.  Defined on integral types.
  245.  
  246. `&&'
  247.      Logical AND.  Defined on integral types.
  248.  
  249. `|'
  250.      Bitwise OR.  Defined on integral types.
  251.  
  252. `^'
  253.      Bitwise exclusive-OR.  Defined on integral types.
  254.  
  255. `&'
  256.      Bitwise AND.  Defined on integral types.
  257.  
  258. `==, !='
  259.      Equality and inequality.  Defined on scalar types.  The value of
  260.      these expressions is 0 for false and non-zero for true.
  261.  
  262. `<, >, <=, >='
  263.      Less than, greater than, less than or equal, greater than or
  264.      equal.  Defined on scalar types.  The value of these
  265.      expressions is 0 for false and non-zero for true.
  266.  
  267. `<<, >>'
  268.      left shift, and right shift.  Defined on integral types.
  269.  
  270. `@'
  271.      The GDB "artificial array" operator (*note Expressions::.).
  272.  
  273. `+, -'
  274.      Addition and subtraction.  Defined on integral types,
  275.      floating-point types and pointer types.
  276.  
  277. `*, /, %'
  278.      Multiplication, division, and modulus.  Multiplication and
  279.      division are defined on integral and floating-point types. 
  280.      Modulus is defined on integral types.
  281.  
  282. `++, --'
  283.      Increment and decrement.  When appearing before a variable, the
  284.      operation is performed before the variable is used in an
  285.      expression; when appearing after it, the variable's value is
  286.      used before the operation takes place.
  287.  
  288. `*'
  289.      Pointer dereferencing.  Defined on pointer types.  Same
  290.      precedence as `++'.
  291.  
  292. `&'
  293.      Address operator.  Defined on variables.  Same precedence as `++'.
  294.  
  295. `-'
  296.      Negative.  Defined on integral and floating-point types.  Same
  297.      precedence as `++'.
  298.  
  299. `!'
  300.      Logical negation.  Defined on integral types.  Same precedence
  301.      as `++'.
  302.  
  303. `~'
  304.      Bitwise complement operator.  Defined on integral types.  Same
  305.      precedence as `++'.
  306.  
  307. `., ->'
  308.      Structure member, and pointer-to-structure member.  For
  309.      convenience, GDB regards the two as equivalent, choosing
  310.      whether to dereference a pointer based on the stored type
  311.      information.  Defined on `struct's and `union's.
  312.  
  313. `[]'
  314.      Array indexing.  `A[I]' is defined as `*(A+I)'.  Same precedence
  315.      as `->'.
  316.  
  317. `()'
  318.      Function parameter list.  Same precedence as `->'.
  319.  
  320. `::'
  321.      C++ scope resolution operator.  Defined on `struct', `union',
  322.      and `class' types.
  323.  
  324. `::'
  325.      The GDB scope operator (*note Expressions::.).  Same precedence
  326.      as `::', above.
  327.  
  328. 
  329. File: gdb.info,  Node: C Constants,  Next: Cplusplus expressions,  Prev: C Operators,  Up: C
  330.  
  331. C and C++ Constants
  332. ...................
  333.  
  334.    GDB allows you to express the constants of C and C++ in the
  335. following ways:
  336.  
  337.    * Integer constants are a sequence of digits.  Octal constants are
  338.      specified by a leading `0' (ie. zero), and hexadecimal
  339.      constants by a leading `0x' or `0X'.  Constants may also end
  340.      with an `l', specifying that the constant should be treated as
  341.      a `long' value.
  342.  
  343.    * Floating point constants are a sequence of digits, followed by a
  344.      decimal point, followed by a sequence of digits, and optionally
  345.      followed by an exponent.  An exponent is of the form:
  346.      `e[[+]|-]NNN', where NNN is another sequence of digits.  The
  347.      `+' is optional for positive exponents.
  348.  
  349.    * Enumerated constants consist of enumerated identifiers, or their
  350.      integral equivalents.
  351.  
  352.    * Character constants are a single character surrounded by single
  353.      quotes (`''), or a number--the ordinal value of the
  354.      corresponding character (usually its ASCII value).  Within
  355.      quotes, the single character may be represented by a letter or
  356.      by "escape sequences", which are of the form `\NNN', where NNN
  357.      is the octal representation of the character's ordinal value;
  358.      or of the form `\X', where `X' is a predefined special
  359.      character--for example, `\n' for newline.
  360.  
  361.    * String constants are a sequence of character constants
  362.      surrounded by double quotes (`"').
  363.  
  364.    * Pointer constants are an integral value.
  365.  
  366. 
  367. File: gdb.info,  Node: Cplusplus expressions,  Next: C Defaults,  Prev: C Constants,  Up: C
  368.  
  369. C++ Expressions
  370. ...............
  371.  
  372.    GDB's expression handling has the following extensions to
  373. interpret a significant subset of C++ expressions:
  374.  
  375.   1. Member function calls are allowed; you can use expressions like
  376.  
  377.           count = aml->GetOriginal(x, y)
  378.  
  379.   2. While a member function is active (in the selected stack frame),
  380.      your expressions have the same namespace available as the
  381.      member function; that is, GDB allows implicit references to the
  382.      class instance pointer `this' following the same rules as C++.
  383.  
  384.   3. You can call overloaded functions; GDB will resolve the function
  385.      call to the right definition, with one restriction--you must
  386.      use arguments of the type required by the function that you
  387.      want to call.  GDB will not perform conversions requiring
  388.      constructors or user-defined type operators.
  389.  
  390.   4. GDB understands variables declared as C++ references; you can
  391.      use them in expressions just as you do in C++ source--they are
  392.      automatically dereferenced.
  393.  
  394.         In the parameter list shown when GDB displays a frame, the
  395.      values of reference variables are not displayed (unlike other
  396.      variables); this avoids clutter, since references are often
  397.      used for large structures.  The *address* of a reference
  398.      variable is always shown, unless you've specified `set print
  399.      address off'.
  400.  
  401.   5. GDB supports the C++ name resolution operator `::'--your
  402.      expressions can use it just as expressions in your program do. 
  403.      Since one scope may be defined in another, you can use `::'
  404.      repeatedly if necessary, for example in an expression like
  405.      `SCOPE1::SCOPE2::NAME'.  GDB also allows resolving name scope
  406.      by reference to source files, in both C and C++ debugging;
  407.      *note Variables::..
  408.  
  409. 
  410. File: gdb.info,  Node: C Defaults,  Next: C Checks,  Prev: Cplusplus expressions,  Up: C
  411.  
  412. C and C++ Defaults
  413. ..................
  414.  
  415.    If you allow GDB to set type and range checking automatically,
  416. they both default to `off' whenever the working language changes to
  417. C/C++.  This happens regardless of whether you, or GDB, selected the
  418. working language.
  419.  
  420.    If you allow GDB to set the language automatically, it sets the
  421. working language to C/C++ on entering code compiled from a source
  422. file whose name ends with `.c' or `.cc'.  *Note Having GDB infer the
  423. source language: Automatically, for further details.
  424.  
  425. 
  426. File: gdb.info,  Node: C Checks,  Next: Debugging C,  Prev: C Defaults,  Up: C
  427.  
  428. C and C++ Type and Range Checks
  429. ...............................
  430.  
  431.      *Warning:* in this release, GDB does not yet perform type or
  432.      range checking.
  433.  
  434.    By default, when GDB parses C or C++ expressions, type checking is
  435. not used.  However, if you turn type checking on, GDB will consider
  436. two variables type equivalent if:
  437.  
  438.    * The two variables are structured and have the same structure,
  439.      union, or enumerated tag.
  440.  
  441.    * Two two variables have the same type name, or types that have
  442.      been declared equivalent through `typedef'.
  443.  
  444.    Range checking, if turned on, is done on mathematical operations. 
  445. Array indices are not checked, since they are often used to index a
  446. pointer that is not itself an array.
  447.  
  448. 
  449. File: gdb.info,  Node: Debugging C,  Next: Debugging C plus plus,  Prev: C Checks,  Up: C
  450.  
  451. GDB and C
  452. .........
  453.  
  454.    The `set print union' and `show print union' commands apply to the
  455. `union' type.  When set to `on', any `union' that is inside a
  456. `struct' or `class' will also be printed.  Otherwise, it will appear
  457. as `{...}'.
  458.  
  459.    The `@' operator aids in the debugging of dynamic arrays, formed
  460. with pointers and a memory allocation function.  (*note
  461. Expressions::.)
  462.  
  463. 
  464. File: gdb.info,  Node: Debugging C plus plus,  Prev: Debugging C,  Up: C
  465.  
  466. GDB Commands for C++
  467. ....................
  468.  
  469.    Some GDB commands are particularly useful with C++, and some are
  470. designed specifically for use with C++.  Here is a summary:
  471.  
  472. `breakpoint menus'
  473.      When you want a breakpoint in a function whose name is
  474.      overloaded, GDB's breakpoint menus help you specify which
  475.      function definition you want.  *Note Breakpoint Menus::.
  476.  
  477. `rbreak REGEX'
  478.      Setting breakpoints using regular expressions is helpful for
  479.      setting breakpoints on overloaded functions that are not
  480.      members of any special classes.  *Note Set Breaks::.
  481.  
  482. `catch EXCEPTIONS'
  483. `info catch'
  484.      Debug C++ exception handling using these commands.  *Note
  485.      Exception Handling::.
  486.  
  487. `ptype TYPENAME'
  488.      Print inheritance relationships as well as other information for
  489.      type TYPENAME.  *Note Symbols::.
  490.  
  491. `set print demangle'
  492. `show print demangle'
  493. `set print asm-demangle'
  494. `show print asm-demangle'
  495.      Control whether C++ symbols display in their source form, both
  496.      when displaying code as C++ source and when displaying
  497.      disassemblies.  *Note Print Settings::.
  498.  
  499. `set print object'
  500. `show print object'
  501.      Choose whether to print derived (actual) or declared types of
  502.      objects.  *Note Print Settings::.
  503.  
  504. `set print vtbl'
  505. `show print vtbl'
  506.      Control the format for printing virtual function tables.  *Note
  507.      Print Settings::.
  508.  
  509. 
  510. File: gdb.info,  Node: Modula-2,  Prev: C,  Up: Support
  511.  
  512. Modula-2
  513. --------
  514.  
  515.    The extensions made to GDB to support Modula-2 support output from
  516. the GNU Modula-2 compiler (which is currently being developed). 
  517. Other Modula-2 compilers are not currently supported, and attempting
  518. to debug executables produced by them will most likely result in an
  519. error as GDB reads in the executable's symbol table.
  520.  
  521. * Menu:
  522.  
  523. * M2 Operators::                Built-in operators
  524. * Builtin Func/Proc::           Built-in Functions and Procedures
  525. * M2 Constants::                Modula-2 Constants
  526. * M2 Defaults::                 Default settings for Modula-2
  527. * Deviations::                  Deviations from standard Modula-2
  528. * M2 Checks::                   Modula-2 Type and Range Checks
  529. * M2 Scope::                    The scope operators `::' and `.'
  530. * GDB/M2::                      GDB and Modula-2
  531.  
  532. 
  533. File: gdb.info,  Node: M2 Operators,  Next: Builtin Func/Proc,  Prev: Modula-2,  Up: Modula-2
  534.  
  535. Operators
  536. .........
  537.  
  538.    Operators must be defined on values of specific types.  For
  539. instance, `+' is defined on numbers, but not on structures. 
  540. Operators are often defined on groups of types.  For the purposes of
  541. Modula-2, the following definitions hold:
  542.  
  543.    * *Integral types* consist of `INTEGER', `CARDINAL', and their
  544.      subranges.
  545.  
  546.    * *Character types* consist of `CHAR' and its subranges.
  547.  
  548.    * *Floating-point types* consist of `REAL'.
  549.  
  550.    * *Pointer types* consist of anything declared as `POINTER TO TYPE'.
  551.  
  552.    * *Scalar types* consist of all of the above.
  553.  
  554.    * *Set types* consist of `SET's and `BITSET's.
  555.  
  556.    * *Boolean types* consist of `BOOLEAN'.
  557.  
  558. The following operators are supported, and appear in order of
  559. increasing
  560. precedence:
  561.  
  562. `,'
  563.      Function argument or array index separator.
  564.  
  565. `:='
  566.      Assignment.  The value of VAR `:=' VALUE is VALUE.
  567.  
  568. `<, >'
  569.      Less than, greater than on integral, floating-point, or
  570.      enumerated types.
  571.  
  572. `<=, >='
  573.      Less than, greater than, less than or equal to, greater than or
  574.      equal to on integral, floating-point and enumerated types, or
  575.      set inclusion on set types.  Same precedence as `<'.
  576.  
  577. `=, <>, #'
  578.      Equality and two ways of expressing inequality, valid on scalar
  579.      types.  Same precedence as `<'.  In GDB scripts, only `<>' is
  580.      available for inequality, since `#' conflicts with the script
  581.      comment character.
  582.  
  583. `IN'
  584.      Set membership.  Defined on set types and the types of their
  585.      members.  Same precedence as `<'.
  586.  
  587. `OR'
  588.      Boolean disjunction.  Defined on boolean types.
  589.  
  590. `AND, &'
  591.      Boolean conjuction.  Defined on boolean types.
  592.  
  593. `@'
  594.      The GDB "artificial array" operator (*note Expressions::.).
  595.  
  596. `+, -'
  597.      Addition and subtraction on integral and floating-point types,
  598.      or union and difference on set types.
  599.  
  600. `*'
  601.      Multiplication on integral and floating-point types, or set
  602.      intersection on set types.
  603.  
  604. `/'
  605.      Division on floating-point types, or symmetric set difference on
  606.      set types.  Same precedence as `*'.
  607.  
  608. `DIV, MOD'
  609.      Integer division and remainder.  Defined on integral types. 
  610.      Same precedence as `*'.
  611.  
  612. `-'
  613.      Negative. Defined on `INTEGER's and `REAL's.
  614.  
  615. `^'
  616.      Pointer dereferencing.  Defined on pointer types.
  617.  
  618. `NOT'
  619.      Boolean negation.  Defined on boolean types.  Same precedence as
  620.      `^'.
  621.  
  622. `.'
  623.      `RECORD' field selector.  Defined on `RECORD's.  Same precedence
  624.      as `^'.
  625.  
  626. `[]'
  627.      Array indexing.  Defined on `ARRAY's.  Same precedence as `^'.
  628.  
  629. `()'
  630.      Procedure argument list.  Defined on `PROCEDURE's.  Same
  631.      precedence as `^'.
  632.  
  633. `::, .'
  634.      GDB and Modula-2 scope operators.
  635.  
  636.      *Warning:* Sets and their operations are not yet supported, so
  637.      GDB will treat the use of the operator `IN', or the use of
  638.      operators `+', `-', `*', `/', `=', , `<>', `#', `<=', and `>='
  639.      on sets as an error.
  640.  
  641. 
  642. File: gdb.info,  Node: Builtin Func/Proc,  Next: M2 Constants,  Prev: M2 Operators,  Up: Modula-2
  643.  
  644. Built-in Functions and Procedures
  645. .................................
  646.  
  647.    Modula-2 also makes available several built-in procedures and
  648. functions.  In describing these, the following metavariables are used:
  649.  
  650. A
  651.      represents an `ARRAY' variable.
  652.  
  653. C
  654.      represents a `CHAR' constant or variable.
  655.  
  656. I
  657.      represents a variable or constant of integral type.
  658.  
  659. M
  660.      represents an identifier that belongs to a set.  Generally used
  661.      in the same function with the metavariable S.  The type of S
  662.      should be `SET OF MTYPE' (where MTYPE is the type of M.
  663.  
  664. N
  665.      represents a variable or constant of integral or floating-point
  666.      type.
  667.  
  668. R
  669.      represents a variable or constant of floating-point type.
  670.  
  671. T
  672.      represents a type.
  673.  
  674. V
  675.      represents a variable.
  676.  
  677. X
  678.      represents a variable or constant of one of many types.  See the
  679.      explanation of the function for details.
  680.  
  681.    All Modula-2 built-in procedures also return a result, described
  682. below.
  683.  
  684. `ABS(N)'
  685.      Returns the absolute value of N.
  686.  
  687. `CAP(C)'
  688.      If C is a lower case letter, it returns its upper case
  689.      equivalent, otherwise it returns its argument
  690.  
  691. `CHR(I)'
  692.      Returns the character whose ordinal value is I.
  693.  
  694. `DEC(V)'
  695.      Decrements the value in the variable V.  Returns the new value.
  696.  
  697. `DEC(V,I)'
  698.      Decrements the value in the variable V by I.  Returns the new
  699.      value.
  700.  
  701. `EXCL(M,S)'
  702.      Removes the element M from the set S.  Returns the new set.
  703.  
  704. `FLOAT(I)'
  705.      Returns the floating point equivalent of the integer I.
  706.  
  707. `HIGH(A)'
  708.      Returns the index of the last member of A.
  709.  
  710. `INC(V)'
  711.      Increments the value in the variable V.  Returns the new value.
  712.  
  713. `INC(V,I)'
  714.      Increments the value in the variable V by I.  Returns the new
  715.      value.
  716.  
  717. `INCL(M,S)'
  718.      Adds the element M to the set S if it is not already there. 
  719.      Returns the new set.
  720.  
  721. `MAX(T)'
  722.      Returns the maximum value of the type T.
  723.  
  724. `MIN(T)'
  725.      Returns the minimum value of the type T.
  726.  
  727. `ODD(I)'
  728.      Returns boolean TRUE if I is an odd number.
  729.  
  730. `ORD(X)'
  731.      Returns the ordinal value of its argument.  For example, the
  732.      ordinal value of a character is its ASCII value (on machines
  733.      supporting the ASCII character set).  X must be of an ordered
  734.      type, which include integral, character and enumerated types.
  735.  
  736. `SIZE(X)'
  737.      Returns the size of its argument.  X can be a variable or a type.
  738.  
  739. `TRUNC(R)'
  740.      Returns the integral part of R.
  741.  
  742. `VAL(T,I)'
  743.      Returns the member of the type T whose ordinal value is I.
  744.  
  745.      *Warning:*  Sets and their operations are not yet supported, so
  746.      GDB will treat the use of procedures `INCL' and `EXCL' as an
  747.      error.
  748.  
  749. 
  750. File: gdb.info,  Node: M2 Constants,  Next: M2 Defaults,  Prev: Builtin Func/Proc,  Up: Modula-2
  751.  
  752. Constants
  753. .........
  754.  
  755.    GDB allows you to express the constants of Modula-2 in the
  756. following ways:
  757.  
  758.    * Integer constants are simply a sequence of digits.  When used in
  759.      an expression, a constant is interpreted to be type-compatible
  760.      with the rest of the expression.  Hexadecimal integers are
  761.      specified by a trailing `H', and octal integers by a trailing
  762.      `B'.
  763.  
  764.    * Floating point constants appear as a sequence of digits,
  765.      followed by a decimal point and another sequence of digits.  An
  766.     
  767.      optional exponent can then be specified, in the form
  768.      `E[+|-]NNN', where `[+|-]NNN' is the desired exponent.  All of
  769.      the digits of the floating point constant must be valid decimal
  770.      (base 10) digits.
  771.  
  772.    * Character constants consist of a single character enclosed by a
  773.      pair of like quotes, either single (`'') or double (`"').  They
  774.      may also be expressed by their ordinal value (their ASCII
  775.      value, usually) followed by a `C'.
  776.  
  777.    * String constants consist of a sequence of characters enclosed by
  778.      a pair of like quotes, either single (`'') or double (`"'). 
  779.      Escape sequences in the style of C are also allowed.  *Note C
  780.      Constants::, for a brief explanation of escape sequences.
  781.  
  782.    * Enumerated constants consist of an enumerated identifier.
  783.  
  784.    * Boolean constants consist of the identifiers `TRUE' and `FALSE'.
  785.  
  786.    * Pointer constants consist of integral values only.
  787.  
  788.    * Set constants are not yet supported.
  789.  
  790. 
  791. File: gdb.info,  Node: M2 Defaults,  Next: Deviations,  Prev: M2 Constants,  Up: Modula-2
  792.  
  793. Modula-2 Defaults
  794. .................
  795.  
  796.    If type and range checking are set automatically by GDB, they both
  797. default to `on' whenever the working language changes to Modula-2. 
  798. This happens regardless of whether you, or GDB, selected the working
  799. language.
  800.  
  801.    If you allow GDB to set the language automatically, then entering
  802. code compiled from a file whose name ends with `.mod' will set the
  803. working language to Modula-2. *Note Having GDB set the language
  804. automatically:
  805. Automatically,
  806. for further details.
  807.  
  808. 
  809. File: gdb.info,  Node: Deviations,  Next: M2 Checks,  Prev: M2 Defaults,  Up: Modula-2
  810.  
  811. Deviations from Standard Modula-2
  812. .................................
  813.  
  814.    A few changes have been made to make Modula-2 programs easier to
  815. debug.  This is done primarily via loosening its type strictness:
  816.  
  817.    * Unlike in standard Modula-2, pointer constants can be formed by
  818.      integers.  This allows you to modify pointer variables during
  819.      debugging.  (In standard Modula-2, the actual address contained
  820.      in a pointer variable is hidden from you; it can only be
  821.      modified through direct assignment to another pointer variable
  822.      or expression that returned a pointer.)
  823.  
  824.    * C escape sequences can be used in strings and characters to
  825.      represent non-printable characters.  GDB will print out strings
  826.      with these escape sequences embedded.  Single non-printable
  827.      characters are printed using the `CHR(NNN)' format.
  828.  
  829.    * The assignment operator (`:=') returns the value of its
  830.      right-hand argument.
  831.  
  832.    * All builtin procedures both modify *and* return their argument.
  833.  
  834. 
  835. File: gdb.info,  Node: M2 Checks,  Next: M2 Scope,  Prev: Deviations,  Up: Modula-2
  836.  
  837. Modula-2 Type and Range Checks
  838. ..............................
  839.  
  840.      *Warning:* in this release, GDB does not yet perform type or
  841.      range checking.
  842.  
  843.    GDB considers two Modula-2 variables type equivalent if:
  844.  
  845.    * They are of types that have been declared equivalent via a `TYPE
  846.      T1 = T2' statement
  847.  
  848.    * They have been declared on the same line.  (Note:  This is true
  849.      of the GNU Modula-2 compiler, but it may not be true of other
  850.      compilers.)
  851.  
  852.    As long as type checking is enabled, any attempt to combine
  853. variables whose types are not equivalent is an error.
  854.  
  855.    Range checking is done on all mathematical operations, assignment,
  856. array index bounds, and all builtin functions and procedures.
  857.  
  858. 
  859. File: gdb.info,  Node: M2 Scope,  Next: GDB/M2,  Prev: M2 Checks,  Up: Modula-2
  860.  
  861. The scope operators `::' and `.'
  862. ................................
  863.  
  864.    There are a few subtle differences between the Modula-2 scope
  865. operator (`.') and the GDB scope operator (`::').  The two have
  866. similar
  867. syntax:
  868.  
  869.  
  870.      MODULE . ID
  871.      SCOPE :: ID
  872.  
  873. where SCOPE is the name of a module or a procedure, MODULE the name
  874. of a module, and ID is any delcared identifier within the program,
  875. except another module.
  876.  
  877.    Using the `::' operator makes GDB search the scope specified by
  878. SCOPE for the identifier ID.  If it is not found in the specified
  879. scope, then GDB will search all scopes enclosing the one specified
  880. by SCOPE.
  881.  
  882.    Using the `.' operator makes GDB search the current scope for the
  883. identifier specified by ID that was imported from the definition
  884. module specified by MODULE.  With this operator, it is an error if
  885. the identifier ID was not imported from definition module MODULE, or
  886. if ID is not an identifier in MODULE.
  887.  
  888. 
  889. File: gdb.info,  Node: GDB/M2,  Prev: M2 Scope,  Up: Modula-2
  890.  
  891. GDB and Modula-2
  892. ................
  893.  
  894.    Some GDB commands have little use when debugging Modula-2 programs.
  895. Five subcommands of `set print' and `show print' apply specifically
  896. to C and C++: `vtbl', `demangle', `asm-demangle', `object', and
  897. `union'.  The first four apply to C++, and the last to C's `union'
  898. type, which has no direct analogue in Modula-2.
  899.  
  900.    The `@' operator (*note Expressions::.), while available while
  901. using any language, is not useful with Modula-2.  Its intent is to
  902. aid the debugging of "dynamic arrays", which cannot be created in
  903. Modula-2 as they can in C or C++.  However, because an address can
  904. be
  905. specified by an integral constant, the construct `{TYPE}ADREXP' is
  906. still useful.  (*note Expressions::.)
  907.  
  908.    In GDB scripts, the Modula-2 inequality operator `#' is
  909. interpreted as the beginning of a comment.  Use `<>' instead.
  910.  
  911. 
  912. File: gdb.info,  Node: Symbols,  Next: Altering,  Prev: Languages,  Up: Top
  913.  
  914. Examining the Symbol Table
  915. **************************
  916.  
  917.    The commands described in this section allow you to inquire about
  918. the symbols (names of variables, functions and types) defined in
  919. your program.  This information is inherent in the text of your
  920. program and does not change as the program executes.  GDB finds it
  921. in
  922. your program's symbol table, in the file indicated when you started
  923. GDB (*note File Options::.), or by one of the file-management
  924. commands (*note Files::.).
  925.  
  926. `info address SYMBOL'
  927.      Describe where the data for SYMBOL is stored.  For a register
  928.      variable, this says which register it is kept in.  For a
  929.      non-register local variable, this prints the stack-frame offset
  930.      at which the variable is always stored.
  931.  
  932.      Note the contrast with `print &SYMBOL', which does not work at
  933.      all for a register variables, and for a stack local variable
  934.      prints the exact address of the current instantiation of the
  935.      variable.
  936.  
  937. `whatis EXP'
  938.      Print the data type of expression EXP.  EXP is not actually
  939.      evaluated, and any side-effecting operations (such as
  940.      assignments or function calls) inside it do not take place. 
  941.     
  942.      *Note Expressions::.
  943.  
  944. `whatis'
  945.      Print the data type of `$', the last value in the value history.
  946.  
  947. `ptype TYPENAME'
  948.      Print a description of data type TYPENAME.  TYPENAME may be the
  949.      name of a type, or for C code it may have the form `struct
  950.      STRUCT-TAG', `union UNION-TAG' or `enum ENUM-TAG'.
  951.  
  952. `ptype EXP'
  953. `ptype'
  954.      Print a description of the type of expression EXP.  `ptype'
  955.      differs from `whatis' by printing a detailed description,
  956.      instead of just the name of the type.  For example, if your
  957.      program declares a variable as
  958.  
  959.           struct complex {double real; double imag;} v;
  960.  
  961.      compare the output of the two commands:
  962.  
  963.           (gdb) whatis v
  964.           type = struct complex
  965.           (gdb) ptype v
  966.           type = struct complex {
  967.               double real;
  968.               double imag;
  969.           }
  970.  
  971.      As with `whatis', using `ptype' without an argument refers to
  972.      the type of `$', the last value in the value history.
  973.  
  974. `info types REGEXP'
  975. `info types'
  976.      Print a brief description of all types whose name matches REGEXP
  977.      (or all types in your program, if you supply no argument). 
  978.      Each complete typename is matched as though it were a complete
  979.      line; thus, `i type value' gives information on all types in
  980.      your program whose name includes the string `value', but `i
  981.      type ^value$' gives information only on types whose complete
  982.      name is `value'.
  983.  
  984.      This command differs from `ptype' in two ways: first, like
  985.      `whatis', it does not print a detailed description; second, it
  986.      lists all source files where a type is defined.
  987.  
  988. `info source'
  989.      Show the name of the current source file--that is, the source
  990.      file for the function containing the current point of
  991.      execution--and the language it was written in.
  992.  
  993. `info sources'
  994.      Print the names of all source files in the program for which
  995.      there is debugging information, organized into two lists: files
  996.      whose symbols have already been read, and files whose symbols
  997.      will be read when needed.
  998.  
  999. `info functions'
  1000.      Print the names and data types of all defined functions.
  1001.  
  1002. `info functions REGEXP'
  1003.      Print the names and data types of all defined functions whose
  1004.      names contain a match for regular expression REGEXP.  Thus,
  1005.      `info fun step' finds all functions whose names include `step';
  1006.      `info fun ^step' finds those whose names start with `step'.
  1007.  
  1008. `info variables'
  1009.      Print the names and data types of all variables that are
  1010.      declared outside of functions (i.e., excluding local variables).
  1011.  
  1012. `info variables REGEXP'
  1013.      Print the names and data types of all variables (except for
  1014.      local variables) whose names contain a match for regular
  1015.      expression REGEXP.
  1016.  
  1017. `printsyms FILENAME'
  1018. `printpsyms FILENAME'
  1019.      Write a dump of debugging symbol data into the file FILENAME. 
  1020.      These commands are used to debug the GDB symbol-reading code. 
  1021.      Only symbols with debugging data are included.  If you use
  1022.      `printsyms', GDB includes all the symbols for which it has
  1023.      already collected full details: that is, FILENAME reflects
  1024.      symbols for only those files whose symbols GDB has read.  You
  1025.      can use the command `info sources' to find out which files
  1026.      these are.  If you use `printpsyms', the dump also shows
  1027.      information about symbols that GDB only knows partially--that
  1028.      is, symbols defined in files that GDB has skimmed, but not yet
  1029.      read completely.  The description of `symbol-file' describes
  1030.      how GDB reads symbols; both commands are described under *Note
  1031.      Files::.
  1032.  
  1033. 
  1034. File: gdb.info,  Node: Altering,  Next: GDB Files,  Prev: Symbols,  Up: Top
  1035.  
  1036. Altering Execution
  1037. ******************
  1038.  
  1039.    Once you think you have found an error in the program, you might
  1040. want to find out for certain whether correcting the apparent error
  1041. would lead to correct results in the rest of the run.  You can find
  1042. the answer by experiment, using the GDB features for altering
  1043. execution of the program.
  1044.  
  1045.    For example, you can store new values into variables or memory
  1046. locations, give the program a signal, restart it at a different
  1047. address, or even return prematurely from a function to its caller.
  1048.  
  1049. * Menu:
  1050.  
  1051. * Assignment::                  Assignment to Variables
  1052. * Jumping::                     Continuing at a Different Address
  1053. * Signaling::                   Giving the Program a Signal
  1054. * Returning::                   Returning from a Function
  1055. * Calling::                     Calling your Program's Functions
  1056. * Patching::                    Patching your Program
  1057.  
  1058. 
  1059. File: gdb.info,  Node: Assignment,  Next: Jumping,  Prev: Altering,  Up: Altering
  1060.  
  1061. Assignment to Variables
  1062. =======================
  1063.  
  1064.    To alter the value of a variable, evaluate an assignment expression.
  1065. *Note Expressions::.  For example,
  1066.  
  1067.      print x=4
  1068.  
  1069. would store the value 4 into the variable `x', and then print the
  1070. value
  1071. of the assignment expression (which is 4).  *Note Languages::, for
  1072. more information on operators in supported languages.
  1073.  
  1074.    If you are not interested in seeing the value of the assignment,
  1075. use
  1076. the `set' command instead of the `print' command.  `set' is really
  1077. the same as `print' except that the expression's value is not
  1078. printed and is not put in the value history (*note Value
  1079. History::.).  The expression is evaluated only for its effects.
  1080.  
  1081.    If the beginning of the argument string of the `set' command
  1082. appears
  1083. identical to a `set' subcommand, use the `set variable' command
  1084. instead of just `set'.  This command is identical to `set' except
  1085. for its lack of subcommands.  For example, a program might well have
  1086. a variable `width'--which leads to an error if we try to set a new
  1087. value with just `set width=13', as we might if `set width' didn't
  1088. happen to be a GDB command:
  1089.  
  1090.      (gdb) whatis width
  1091.      type = double
  1092.      (gdb) p width
  1093.      $4 = 13
  1094.      (gdb) set width=47
  1095.      Invalid syntax in expression.
  1096.  
  1097. The invalid expression, of course, is `=47'.  What we can do in order
  1098. to actually set our program's variable `width' is
  1099.  
  1100.      (gdb) set var width=47
  1101.  
  1102.    GDB allows more implicit conversions in assignments than C does;
  1103. you can freely store an integer value into a pointer variable or
  1104. vice
  1105. versa, and any structure can be converted to any other structure
  1106. that is the same length or shorter.
  1107.  
  1108.    To store values into arbitrary places in memory, use the `{...}'
  1109. construct to generate a value of specified type at a specified
  1110. address (*note Expressions::.).  For example, `{int}0x83040' refers
  1111. to memory location `0x83040' as an integer (which implies a certain
  1112. size and representation in memory), and
  1113.  
  1114.      set {int}0x83040 = 4
  1115.  
  1116. stores the value 4 into that memory location.
  1117.  
  1118. 
  1119. File: gdb.info,  Node: Jumping,  Next: Signaling,  Prev: Assignment,  Up: Altering
  1120.  
  1121. Continuing at a Different Address
  1122. =================================
  1123.  
  1124.    Ordinarily, when you continue the program, you do so at the place
  1125. where it stopped, with the `continue' command.  You can instead
  1126. continue at an address of your own choosing, with the following
  1127. commands:
  1128.  
  1129. `jump LINESPEC'
  1130.      Resume execution at line LINESPEC.  Execution will stop
  1131.      immediately if there is a breakpoint there.  *Note List:: for a
  1132.      description of the different forms of LINESPEC.
  1133.  
  1134.      The `jump' command does not change the current stack frame, or
  1135.      the stack pointer, or the contents of any memory location or
  1136.      any register other than the program counter.  If line LINESPEC
  1137.      is in a different function from the one currently executing,
  1138.      the results may be bizarre if the two functions expect
  1139.      different patterns of arguments or of local variables.  For
  1140.      this
  1141.      reason, the `jump' command requests confirmation if the
  1142.      specified line is not in the function currently executing. 
  1143.      However, even bizarre results are predictable if you are well
  1144.      acquainted with the machine-language code of the program.
  1145.  
  1146. `jump *ADDRESS'
  1147.      Resume execution at the instruction at address ADDRESS.
  1148.  
  1149.    You can get much the same effect as the `jump' command by storing
  1150. a new value into the register `$pc'.  The difference is that this
  1151. does not start the program running; it only changes the address
  1152. where it *will* run when it is continued.  For example,
  1153.  
  1154.      set $pc = 0x485
  1155.  
  1156. causes the next `continue' command or stepping command to execute at
  1157. address 0x485, rather than at the address where the program stopped.
  1158. *Note Continuing and Stepping::.
  1159.  
  1160.    The most common occasion to use the `jump' command is to back up,
  1161. perhaps with more breakpoints set, over a portion of a program that
  1162. has already executed, in order to examine its execution in more
  1163. detail.
  1164.  
  1165. 
  1166. File: gdb.info,  Node: Signaling,  Next: Returning,  Prev: Jumping,  Up: Altering
  1167.  
  1168. Giving the Program a Signal
  1169. ===========================
  1170.  
  1171. `signal SIGNALNUM'
  1172.      Resume execution where the program stopped, but give it
  1173.      immediately the signal number SIGNALNUM.
  1174.  
  1175.      Alternatively, if SIGNALNUM is zero, continue execution without
  1176.      giving a signal.  This is useful when the program stopped on
  1177.      account of a signal and would ordinary see the signal when
  1178.      resumed with the `continue' command; `signal 0' causes it to
  1179.      resume without a signal.
  1180.  
  1181.      `signal' does not repeat when you press RET a second time after
  1182.      executing the command.
  1183.  
  1184. 
  1185. File: gdb.info,  Node: Returning,  Next: Calling,  Prev: Signaling,  Up: Altering
  1186.  
  1187. Returning from a Function
  1188. =========================
  1189.  
  1190. `return'
  1191. `return EXPRESSION'
  1192.      You can cancel execution of a function call with the `return'
  1193.      command.  If you give an EXPRESSION argument, its value is used
  1194.      as the function's return value.
  1195.  
  1196.    When you use `return', GDB discards the selected stack frame (and
  1197. all frames within it).  You can think of this as making the
  1198. discarded frame return prematurely.  If you wish to specify a value
  1199. to be returned, give that value as the argument to `return'.
  1200.  
  1201.    This pops the selected stack frame (*note Selection::.), and any
  1202. other frames inside of it, leaving its caller as the innermost
  1203. remaining frame.  That frame becomes selected.  The specified value
  1204. is stored in the registers used for returning values of functions.
  1205.  
  1206.    The `return' command does not resume execution; it leaves the
  1207. program stopped in the state that would exist if the function had
  1208. just returned.  In contrast, the `finish' command (*note Continuing
  1209. and Stepping::.) resumes execution until the selected stack frame
  1210. returns naturally.
  1211.  
  1212. 
  1213. File: gdb.info,  Node: Calling,  Next: Patching,  Prev: Returning,  Up: Altering
  1214.  
  1215. Calling your Program's Functions
  1216. ================================
  1217.  
  1218. `call EXPR'
  1219.      Evaluate the expression EXPR without displaying `void' returned
  1220.      values.
  1221.  
  1222.    You can use this variant of the `print' command if you want to
  1223. execute a function from your program, but without cluttering the
  1224. output with `void' returned values.  The result is printed and saved
  1225. in the value history, if it is not void.
  1226.  
  1227. 
  1228. File: gdb.info,  Node: Patching,  Prev: Calling,  Up: Altering
  1229.  
  1230. Patching your Program
  1231. =====================
  1232.  
  1233.    By default, GDB opens the file containing your program's
  1234. executable code (or the corefile) read-only.  This prevents
  1235. accidental
  1236. alterations to machine code; but it also prevents you from
  1237. intentionally patching your program's binary.
  1238.  
  1239.    If you'd like to be able to patch the binary, you can specify that
  1240. explicitly with the `set write' command.  For example, you might
  1241. want to turn on internal debugging flags, or even to make emergency
  1242. repairs.
  1243.  
  1244. `set write on'
  1245. `set write off'
  1246.      If you specify `set write on', GDB will open executable and core
  1247.      files for both reading and writing; if you specify `set write
  1248.      off' (the default), GDB will open them read-only.
  1249.  
  1250.      If you've already loaded a file, you must load it again (using
  1251.      the `exec-file' or `core-file' command) after changing `set
  1252.      write', for your new setting to take effect.
  1253.  
  1254. `show write'
  1255.      Display whether executable files and core files will be opened
  1256.      for writing as well as reading.
  1257.  
  1258. 
  1259. File: gdb.info,  Node: GDB Files,  Next: Targets,  Prev: Altering,  Up: Top
  1260.  
  1261. GDB's Files
  1262. ***********
  1263.  
  1264. * Menu:
  1265.  
  1266. * Files::                       Commands to Specify Files
  1267. * Symbol Errors::               Errors Reading Symbol Files
  1268.  
  1269.